<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/static/layui/css/layui.css">
</head>
<body style="background: #f1f1f1;">
	<div id="assess">
		<form class="layui-form">
			<table class="layui-table">
				<thead>
					<tr>
						<th>开放班级</th>
						<th>是否开放</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${data}" var="d">
						<tr>
							<td>${d.tbclass.name}</td>
							<c:if test="${d.isstart==true }">
								<td><input type="checkbox" id="test1" value="${d.id}"
									checked lay-filter="status" lay-skin="switch" lay-text="开启|关闭"></td>
							</c:if>
							<c:if test="${d.isstart!=true }">
								<td><input type="checkbox" id="test1" value="${d.id}"
									lay-filter="status" lay-skin="switch" lay-text="开启|关闭"></td>
							</c:if>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</form>
	</div>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/static/js/jquery-1.12.4.min.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/static/layui/layui.js"></script>
	<script type="text/javascript">
		layui.use('form', function() {
			var form = layui.form;

			form.on('switch(status)', function(obj) {
				var isstart = obj.elem.checked;
				var id = obj.elem.value;
				$.post("${pageContext.request.contextPath }/video/tijiao", {
					id : id,
					isstart : isstart
				}, function(msg) {
					layui.use('layer', function() {
						var layer = layui.layer;
						layer.msg(msg, {
							time : 2000
						});
					});
				});
			});
		});
	</script>
</body>
</html>